Example #1
0
    def test_freeze(self):
        c = Castor(self.test_root)
        c.apply()

        repo_dir = path.join(self.test_root, 'lodge')
        g = git.Git(repo_dir)
        g.checkout('master')

        modified_file = path.join(self.test_root, 'lodge', 'test.txt')
        with open(modified_file, 'w') as f:
            f.write('Saluton')

        r = git.Repo(repo_dir)
        r.index.add([modified_file])
        r.index.commit('Translated to Esperanto')
        r.create_tag('tag2')

        c.freeze()

        with open(path.join(self.test_root, 'Castorfile'), 'r') as f:
            cf = json.load(f)
            self.assertEqual(cf['lodge'][0]['version'], 'tag2')

        with open(path.join(self.test_root, 'dam', 'test.txt')) as f:
            self.assertEqual('Saluton', f.read())
Example #2
0
    def test_apply_file(self):
        file_path = path.join(self.workdir, ".htaccess")
        c = Castor(self.test_root)
        c.apply_file("files/htaccess", file_path)

        with open(file_path, "r") as f:
            self.assertEqual(f.read(), "Require all granted\n")
Example #3
0
    def test_post_freeze(self):
        c = Castor(self.test_root)
        c.apply()

        c.freeze()

        self.assertTrue(path.exists(path.join(self.test_root, 'dam', 'modules', 'test', 'foo')))
Example #4
0
    def test_freeze(self):
        c = Castor(self.test_root)
        c.apply()

        repo_dir = path.join(self.test_root, "lodge")
        g = git.Git(repo_dir)
        g.checkout("master")

        modified_file = path.join(self.test_root, "lodge", "test.txt")
        with open(modified_file, "w") as f:
            f.write("Saluton")

        r = git.Repo(repo_dir)
        r.index.add([modified_file])
        r.index.commit("Translated to Esperanto")
        r.create_tag("tag2")

        c.freeze()

        with open(path.join(self.test_root, "Castorfile"), "r") as f:
            cf = json.load(f)
            self.assertEqual(cf["lodge"][0]["version"], "tag2")

        with open(path.join(self.test_root, "dam", "test.txt")) as f:
            self.assertEqual("Saluton", f.read())
Example #5
0
    def test_apply_file(self):
        file_path = path.join(self.workdir, '.htaccess')
        c = Castor(self.test_root)
        c.apply_file('files/htaccess', file_path)

        with open(file_path, 'r') as f:
            self.assertEqual(f.read(), 'Require all granted\n')
Example #6
0
    def test_apply(self):
        c = Castor(self.test_root)
        c.apply()

        repo = git.Repo(path.join(self.test_root, "lodge"))
        self.assertEqual(str(repo.head.commit), "cb83f96c803fb1067d7932a808b6f6eddf096ae5")
        self.assertFalse(repo.is_dirty())
        self.assertEqual(repo.untracked_files, [])
Example #7
0
    def test_write_castorfile(self):
        c = Castor(self.test_root)
        c.castorfile["lodge"][0]["version"] = "foo"
        c.write_castorfile()

        with open(path.join(self.test_root, "Castorfile"), "r") as f:
            cf = json.load(f)

        self.assertEqual(cf["lodge"][0]["version"], "foo")
Example #8
0
    def test_apply_git(self):
        repo_path = path.join(self.workdir, "test")
        c = Castor(self.test_root)
        c.apply_git(repo_path, "https://github.com/Xowap/FreneticBunny.git", "0.1")

        repo = git.Repo(repo_path)
        self.assertEqual(str(repo.head.commit), "40ac859b274e9298d29fda83540b3b72bd2f54f0")
        self.assertFalse(repo.is_dirty())
        self.assertEqual(repo.untracked_files, [])
Example #9
0
    def test_write_castorfile(self):
        c = Castor(self.test_root)
        c.castorfile['lodge'][0]['version'] = 'foo'
        c.write_castorfile()

        with open(path.join(self.test_root, 'Castorfile'), 'r') as f:
            cf = json.load(f)

        self.assertEqual(cf['lodge'][0]['version'], 'foo')
Example #10
0
    def test_apply_exec_post_freeze(self):
        c = Castor(self.test_root)
        c.apply(True)

        repo = git.Repo(path.join(self.test_root, 'lodge'))
        self.assertEqual(str(repo.head.commit), 'cb83f96c803fb1067d7932a808b6f6eddf096ae5')
        self.assertFalse(repo.is_dirty())
        self.assertEqual(repo.untracked_files, [])
        self.assertTrue(path.exists(path.join(self.test_root, 'lodge', 'modules', 'test', 'foo')))
Example #11
0
 def test_freeze_files(self):
     c = Castor(self.test_root)
     c.apply()
     c.freeze()
     self.assertTrue(path.exists(path.join(self.test_root, 'dam', '.htaccess')))
     self.assertTrue(path.exists(path.join(
         self.test_root,
         'dam',
         'app/documentation/readme.md'
     )))
Example #12
0
    def test_gather_dam(self):
        c = Castor(self.test_root)
        c.apply()
        c.gather_dam()

        dam_files = set()
        dam_path = path.join(self.test_root, "dam")

        for root, dir_names, file_names in walk(dam_path):
            for file_name in file_names:
                dam_files.add(path.relpath(path.join(root, file_name), dam_path))

        self.assertEqual(dam_files, {"test.txt", "modules/test/youpi.txt", ".htaccess"})
Example #13
0
    def test_gather_dam(self):
        c = Castor(self.test_root)
        c.apply()
        c.gather_dam()

        dam_files = set()
        dam_path = path.join(self.test_root, 'dam')

        for root, dir_names, file_names in walk(dam_path):
            for file_name in file_names:
                dam_files.add(path.relpath(path.join(root, file_name), dam_path))

        self.assertEqual(dam_files, {
            'test.txt',
            'modules/test/youpi.txt',
            'modules/test/foo',
            '.htaccess',
            'app/documentation/readme.md',
        })
Example #14
0
    def test_update_versions(self):
        c = Castor(self.test_root)
        c.apply()

        repo_dir = path.join(self.test_root, "lodge")
        g = git.Git(repo_dir)
        g.checkout("master")

        modified_file = path.join(self.test_root, "lodge", "test.txt")
        with open(modified_file, "w") as f:
            f.write("Saluton")

        r = git.Repo(repo_dir)
        r.index.add([modified_file])
        r.index.commit("Translated to Esperanto")
        r.create_tag("tag2")

        c.update_versions()

        self.assertEqual(c.castorfile["lodge"][0]["version"], "tag2")
Example #15
0
    def test_update_versions(self):
        c = Castor(self.test_root)
        c.apply()

        repo_dir = path.join(self.test_root, 'lodge')
        g = git.Git(repo_dir)
        g.checkout('master')

        modified_file = path.join(self.test_root, 'lodge', 'test.txt')
        with open(modified_file, 'w') as f:
            f.write('Saluton')

        r = git.Repo(repo_dir)
        r.index.add([modified_file])
        r.index.commit('Translated to Esperanto')
        r.create_tag('tag2')

        c.update_versions()

        self.assertEqual(c.castorfile['lodge'][0]['version'], 'tag2')
Example #16
0
    def test_freeze_subdir(self):
        c = Castor(self.test_root)
        c.apply()
        del c

        with open(path.join(self.test_root, "Castorfile"), "r") as f:
            d = json.load(f)

        d["lodge"][2]["version"] = "this-version-does-not-exist"

        with open(path.join(self.test_root, "Castorfile"), "w") as f:
            json.dump(d, f)

        c = Castor(self.test_root)
        c.update_versions()

        self.assertEqual(c.castorfile["lodge"][2]["version"], "tag1")
Example #17
0
    def test_freeze_subdir(self):
        c = Castor(self.test_root)
        c.apply()
        del c

        with open(path.join(self.test_root, 'Castorfile'), 'r') as f:
            d = json.load(f)

        d['lodge'][2]['version'] = 'this-version-does-not-exist'

        with open(path.join(self.test_root, 'Castorfile'), 'w') as f:
            json.dump(d, f)

        c = Castor(self.test_root)
        c.update_versions()

        self.assertEqual(c.castorfile['lodge'][2]['version'], 'tag1')
Example #18
0
 def test_freeze_files(self):
     c = Castor(self.test_root)
     c.apply()
     c.freeze()
     self.assertTrue(path.exists(path.join(self.test_root, "dam", ".htaccess")))