Beispiel #1
0
    def test_git_diffbranch(self):
        git = GitCmd()
        git.do_branch('trial')
        G.change_location_file("Git Crystal")
        git.do_stage('location.json')
        git.do_commit('Player in Git Crystal')
        git.do_diffbranch('')

        expected = "only " + "data,trial are legal branch names\n"
        expected += "usage: diffbranch branch1 branch2\n"
        self.assertEqual(git.output, expected)

        git.do_diffbranch('trial data')
        expected = """diff --git a/location.json b/location.json
index 86b52b7..64e45dc 100644
--- a/location.json
+++ b/location.json
@@ -1,4 +1,4 @@
 {
-    "location":"Mountain Gate"
+    "location":"Git Crystal"
 }
 
"""
        self.assertEqual(git.output, expected)
        command = [G.GIT, '-C', G.repodir, 'branch', '-D', 'trial']
        process = cw.run_process(command)
Beispiel #2
0
    def test_git_diff(self):
        git = GitCmd()

        G.change_location_file("Git Crystal")
        git.do_diff('')

        expected = """diff --git a/location.json b/location.json
index 86b52b7..64e45dc 100644
--- a/location.json
+++ b/location.json
@@ -1,4 +1,4 @@
 {
-    "location":"Mountain Gate"
+    "location":"Git Crystal"
 }
 
"""
        self.assertEqual(git.output, expected)

        git.do_stage('location.json')
        git.do_diffstaged('')
        expected = """diff --git a/location.json b/location.json
index 86b52b7..64e45dc 100644
--- a/location.json
+++ b/location.json
@@ -1,4 +1,4 @@
 {
-    "location":"Mountain Gate"
+    "location":"Git Crystal"
 }
 
"""
        self.assertEqual(git.output, expected)
Beispiel #3
0
    def test_no_conflict_recursive_merge(self):
        git = GitCmd()
        git.do_merge('')
        expected = "No branch names provided"
        self.assertEqual(git.output, expected)

        git.do_merge('octupus merge')
        expected = "Git Crystals does not support merging mulitple branches"
        self.assertEqual(git.output, expected)

        git.do_branch('trial')
        git.do_checkout('trial')
        G.change_location_file("Git Crystal")
        git.do_stage('location.json')
        git.do_commit('Player in Git Crystal')
        git.do_checkout('data')
        git.do_merge('trial')

        command = [G.GIT, '-C', G.repodir, 'branch', '-D', 'trial']
        process = cw.run_process(command)

        expected = """Merge made by the 'recursive' strategy.
 location.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
"""
        self.assertEqual(git.output, expected)
    def test_do_look(self):
        G.change_location_file("Mountain Gate")
        game = GitCrystalsCmd()
        expected = """You are in Mountain Gate
To your north is... Git Crystal
To your south is... 
To your east is... 
To your west is... 
There is no here but you.
"""
        game.do_look('')
        self.assertEqual(game.output, expected)

        expected = """You are in Mountain Gate
To your north is... Git Crystal
To your south is... 
To your east is... 
To your west is... 
"""
        game.do_look('room')
        self.assertEqual(game.output, expected)

        expected = """There is no here but you.\n"""
        game.do_look('people')
        self.assertEqual(game.output, expected)
    def test_display_ground(self):
        G.change_location_file("Git Crystal")

        game = GitCrystalsCmd()
        expected = "In Git Crystal you see...\n    Git Status Tutorial\n    Intro Git Tutorial\n"
        self.assertEqual(game.display_ground(), expected)

        G.change_location_file("Mountain Gate")
 def test_write_data(self):
     game = GitCrystalsCmd()
     G.change_location_file('Git Crystal')
     game.load_data()
     G.change_location_file('Mountain Gate')
     game.write_data()
     file_data = JsonData(G.repodir, "location")
     self.assertEqual(file_data.data['location'], 'Git Crystal')
 def test_create_character(self):
     G.change_location_file("Mountain Gate")
     game = GitCrystalsCmd()
     player = game.player
     self.assertEqual(player.js_location.data['location'], "Mountain Gate")
     princess = game.create_character('princess')
     self.assertEqual(princess.js_location.data['location'],
                      "Dragon's Lair")
Beispiel #8
0
    def test_change_location_file(self):
        with open(G.repodir + '/location.json', 'w') as f:
            f.write('{\n    "location":"Git Crystal"\n}\n\n')
        G.change_location_file('Mountain Gate')

        command = [G.GIT, '-C',G.repodir,'status','--short']
        process = cw.run_process(command)
        output = process.stdout
        expected = ""

        self.assertEqual(output, expected)
Beispiel #9
0
    def test_commit(self):
        git = GitCmd()
        G.change_location_file("Git Crystal")
        git.do_stage('location.json')
        git.do_commit('Player in Git Crystal')

        command = [G.GIT, '-C', G.repodir, 'show-ref', '--heads']
        process = cw.run_process(command)
        self.assertNotEqual(
            process.stdout,
            G.current_commit_sha + " refs/heads/" + G.current_branch + '\n')
Beispiel #10
0
    def test_unstage(self):
        git = GitCmd()
        G.change_location_file("Git Crystal")
        git.do_stage('location.json')
        git.do_unstage('location.json')

        command = [G.GIT, '-C', G.repodir, 'status', '--short']
        process = cw.run_process(command)
        G.change_location_file("Mountain Gate")

        expected = ' M location.json\n'  # location.json has unstaged changes
        self.assertEqual(process.stdout, expected)
Beispiel #11
0
    def test_stage(self):
        git = GitCmd()
        G.change_location_file("Git Crystal")
        git.do_stage('location.json')

        command = [G.GIT, '-C', G.repodir, 'status', '--short']
        process1 = cw.run_process(command)

        G.change_location_file("Mountain Gate")
        command = [G.GIT, '-C', G.repodir, 'reset', 'HEAD', 'location.json']
        process2 = cw.run_process(command)

        expected = 'M  location.json\n'  # location.json is staged
        self.assertEqual(process1.stdout, expected)
    def test_go(self):
        G.change_location_file("Mountain Gate")
        game = GitCrystalsCmd()
        line = 'go north'
        stop = game.onecmd(line)
        game.postcmd(stop, line)
        expected_location = "Git Crystal"
        player_location = game.player.location
        json_file = JsonData(G.repodir, "location")
        file_location = json_file.data['location']

        self.assertEqual(player_location, expected_location)
        self.assertEqual(file_location, expected_location)

        G.change_location_file("Mountain Gate")
    def test_do_perilious_search(self):
        G.change_location_file("Abandoned Treasury")
        game = GitCrystalsCmd()
        line = 'search'
        stop = game.onecmd(line)
        game.postcmd(stop, line)
        expected = """In Abandoned Treasury you see...
    Charcoal
    Treasure Chest Key
"""
        output = game.output
        alive = game.player.js_alive.data['alive']
        game.do_checkoutfile('alive.json')
        game.do_checkoutfile('location.json')

        self.assertEqual(expected, output)
        self.assertFalse(alive)
Beispiel #14
0
    def test_status(self):
        git = GitCmd()
        git.do_status('')

        expected = 'No changes since last commit\n'
        self.assertEqual(git.output, expected)

        G.change_location_file("Git Crystal")

        git.do_status('')
        expected = "    unstaged changes: location.json\n"
        self.assertEqual(git.output, expected)

        git.do_stage('location.json')
        git.do_status('')
        expected = "    staged changes: location.json\n"
        self.assertEqual(git.output, expected)

        G.change_location_file("Stalagmite Central")
        git.do_status('')
        expected = '    staged changes: location.json\n    unstaged changes: location.json\n'
        self.assertEqual(git.output, expected)
Beispiel #15
0
    def test_merge_with_conflicts(self):
        git = GitCmd()

        git.do_branch('trial')
        G.change_location_file("Git Crystal")
        git.do_stage('location.json')
        git.do_commit('Player in Git Crystal')
        git.do_checkout('data')
        G.change_location_file("Stalagmite Central")
        git.do_stage('location.json')
        git.do_merge('trial')
        git.do_resolveleft('location.json')
        git.do_resolveright('location.json')
        git.do_stage('location.json')
        git.do_commit('Merge Branch Trial')
        git.do_status(
            '')  # Get status message after successful merge resolution.

        command = [G.GIT, '-C', G.repodir, 'branch', '-D', 'trial']
        process = cw.run_process(command)

        expected = 'No changes since last commit\n'
        self.assertEqual(git.output, expected)
    def test_do_perilious_search_with_others(self):
        G.change_location_file("Abandoned Treasury")
        G.change_character_info('princess', 'location', 'Abandoned Treasury')
        game = GitCrystalsCmd()

        line = 'search'
        stop = game.onecmd(line)
        game.postcmd(stop, line)

        output = game.output
        alive = game.player.js_alive.data['alive']
        princess_alive = game.characters['princess'].js_alive.data['alive']

        expected = """In Abandoned Treasury you see...
    Charcoal
    Treasure Chest Key\n"""

        game.do_checkoutfile('alive.json')
        game.do_checkoutfile('location.json')
        game.do_checkoutfile('princess/location.json')

        self.assertEqual(expected, output)
        self.assertFalse(alive)
        self.assertFalse(princess_alive)
    def test_display_characters(self):
        G.change_location_file("Mountain Gate")

        game = GitCrystalsCmd()
        expected = 'There is no here but you.\n'
        self.assertEqual(game.display_characters(), expected)

        G.change_location_file("Dragon's Lair")
        game = GitCrystalsCmd()
        expected = "In Dragon's Lair you see...\n    princess\n    grandfather\n    dragon\n"
        self.assertEqual(game.display_characters(), expected)

        G.change_location_file("Mountain Gate")
 def test_load_data(self):
     game = GitCrystalsCmd()
     G.change_location_file('Git Crystal')
     game.load_data()
     expected = 'Git Crystal'
     self.assertEqual(game.player.location, expected)