michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import os michael@0: import posixpath michael@0: michael@0: from dmunit import DeviceManagerTestCase michael@0: michael@0: class Push2TestCase(DeviceManagerTestCase): michael@0: michael@0: def runTest(self): michael@0: """This tests copying a directory structure with files to the device. michael@0: """ michael@0: testroot = posixpath.join(self.dm.getDeviceRoot(), 'infratest') michael@0: self.dm.removeDir(testroot) michael@0: self.dm.mkDir(testroot) michael@0: path = posixpath.join(testroot, 'push2') michael@0: self.dm.pushDir(os.path.join('test-files', 'push2'), path) michael@0: michael@0: # Let's walk the tree and make sure everything is there michael@0: # though it's kind of cheesy, we'll use the validate file to compare michael@0: # hashes - we use the client side hashing when testing the cat command michael@0: # specifically, so that makes this a little less cheesy, I guess. michael@0: self.assertTrue( michael@0: self.dm.dirExists(posixpath.join(testroot, 'push2', 'sub1'))) michael@0: self.assertTrue(self.dm.validateFile( michael@0: posixpath.join(testroot, 'push2', 'sub1', 'file1.txt'), michael@0: os.path.join('test-files', 'push2', 'sub1', 'file1.txt'))) michael@0: self.assertTrue(self.dm.validateFile( michael@0: posixpath.join(testroot, 'push2', 'sub1', 'sub1.1', 'file2.txt'), michael@0: os.path.join('test-files', 'push2', 'sub1', 'sub1.1', 'file2.txt'))) michael@0: self.assertTrue(self.dm.validateFile( michael@0: posixpath.join(testroot, 'push2', 'sub2', 'file3.txt'), michael@0: os.path.join('test-files', 'push2', 'sub2', 'file3.txt'))) michael@0: self.assertTrue(self.dm.validateFile( michael@0: posixpath.join(testroot, 'push2', 'file4.bin'), michael@0: os.path.join('test-files', 'push2', 'file4.bin')))