Example #1
0
    def test_mock_target_root(self):
        '''Verify mock target url

        '''
        target = OpenerTarget('mock:///foo/bar.txt')
        self.assertEqual(type(target), MockTarget)

        # Write to the target
        target.open('w').close()
        self.assertTrue(MockTarget.fs.exists('/foo/bar.txt'))
Example #2
0
    def test_default_target(self):
        '''Verify default local target url

        '''
        target = OpenerTarget(self.local_file)
        self.assertEqual(type(target), LocalTarget)

        # Write to the target
        target.open('w').close()
        self.assertTrue(LocalTarget.fs.exists(self.local_file))
Example #3
0
    def test_default_target(self):
        '''Verify default local target url

        '''
        target = OpenerTarget(self.local_file)
        self.assertEqual(type(target), LocalTarget)

        # Write to the target
        target.open('w').close()
        self.assertTrue(LocalTarget.fs.exists(self.local_file))
Example #4
0
    def test_mock_target_root(self):
        '''Verify mock target url

        '''
        target = OpenerTarget('mock:///foo/bar.txt')
        self.assertEqual(type(target), MockTarget)

        # Write to the target
        target.open('w').close()
        self.assertTrue(MockTarget.fs.exists('/foo/bar.txt'))
Example #5
0
    def test_local_target(self):
        '''Verify basic local target url

        '''
        local_file = "file://{}".format(self.local_file)
        target = OpenerTarget(local_file)
        self.assertEqual(type(target), LocalTarget)

        # Write to the target
        target.open('w').close()
        self.assertTrue(LocalTarget.fs.exists(self.local_file))
Example #6
0
    def test_local_target(self):
        '''Verify basic local target url

        '''
        local_file = "file://{}".format(self.local_file)
        target = OpenerTarget(local_file)
        self.assertEqual(type(target), LocalTarget)

        # Write to the target
        target.open('w').close()
        self.assertTrue(LocalTarget.fs.exists(self.local_file))
Example #7
0
    def test_s3_parse(self, s3_init_patch):
        '''Verify basic s3 target url

        '''
        s3_init_patch.return_value = None

        local_file = "s3://zefr/foo/bar.txt"
        OpenerTarget(local_file)
        s3_init_patch.assert_called_with("s3://zefr/foo/bar.txt")
Example #8
0
    def test_local_tmp_target(self, lt_del_patch, lt_init_patch):
        '''Verify local target url with query string

        '''
        lt_init_patch.return_value = None
        lt_del_patch.return_value = None

        local_file = "file://{}?is_tmp".format(self.local_file)
        OpenerTarget(local_file)
        lt_init_patch.assert_called_with(self.local_file, is_tmp=True)
Example #9
0
    def test_binary_support(self):
        """
        Make sure keyword arguments are preserved through the OpenerTarget
        """
        # Verify we can't normally write binary data
        fp = OpenerTarget("mock://file.txt").open('w')
        self.assertRaises(TypeError, fp.write, b'\x07\x08\x07')

        # Verify the format is passed to the target and write binary data
        fp = OpenerTarget("mock://file.txt",
                          format=luigi.format.MixedUnicodeBytes).open('w')
        fp.write(b'\x07\x08\x07')
        fp.close()
Example #10
0
    def test_s3_parse_param(self, s3_init_patch):
        '''Verify s3 target url with params

        '''
        s3_init_patch.return_value = None

        local_file = "s3://zefr/foo/bar.txt?foo=hello&bar=true"
        OpenerTarget(local_file)
        s3_init_patch.assert_called_with("s3://zefr/foo/bar.txt",
                                         foo='hello',
                                         bar='true')
Example #11
0
    def test_binary_support(self):
        '''Make sure keyword arguments are preserved through the OpenerTarget

        '''
        if six.PY3:
            # Verify we can't normally write binary data
            fp = OpenerTarget("mock://file.txt").open('w')
            self.assertRaises(TypeError, fp.write, b'\x07\x08\x07')

            # Verify the format is passed to the target and write binary data
            fp = OpenerTarget("mock://file.txt",
                              format=luigi.format.MixedUnicodeBytes).open('w')
            fp.write(b'\x07\x08\x07')
            fp.close()
Example #12
0
 def output(self):
     filepath = os.path.join(self.ROOT, self.TYPE, self.FILENAME)
     return OpenerTarget(filepath, format=Nop) # OpenerTarget automatically figures out the correct target from filepath