コード例 #1
0
    def test_closest_confidence_is_correct(self, detect_bo_mock):
        self._detect_bo_values = [[80, MagicMock()], [97, MagicMock()],
                                  [70, MagicMock()]]
        detect_bo_mock.side_effect = self._detect_build_order_returns

        bol = BuildOrderLibrary(self.get_builds())

        closest_build, confidence, closest_build_bod = bol.get_closest_matching_build(
            MagicMock())

        self.assertEqual(97, confidence)
コード例 #2
0
    def test_first_build_with_given_name_is_returned_when_multiple_builds_have_the_same_name(
            self):
        blds = self.get_builds()
        blds[1].build.append(BuildOrderElement(1, "second", 0, 0, 0))
        blds[2].build.append(BuildOrderElement(1, "third", 0, 0, 0))
        blds[2].name = "my_second"

        bol = BuildOrderLibrary(blds)

        bo = bol.get_build_by_name("my_second")

        self.assertEqual("second", bo.build[0].name)
コード例 #3
0
    def test_build_is_placed_at_the_end_of_the_build_list_when_adding_build(
            self):
        bol = BuildOrderLibrary(self.get_builds())

        bol.add_build(BuildOrder(name="my_added_build"))

        self.assertEqual("my_added_build",
                         bol.get_build_by_index(bol.build_count() - 1).name)
コード例 #4
0
    def test_build_is_removed_when_removing_by_build(self):
        blds = self.get_builds()
        bol = BuildOrderLibrary(blds)

        bol.remove_build_by_build_order(blds[1])

        self.assertEqual(2, bol.build_count())
        self.assertIsNone(bol.get_build_by_name("my_second"))
コード例 #5
0
        if event == 'Analyze':
            bod_window['-OUTPUT-'].Update(mngr.get_bod_results_from_replay(
                values[1], values[2]),
                                          append=True)

    bod_window.close()


if __name__ == '__main__':
    import os
    import sys

    sys.path.insert(
        0,
        os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)))

    from metrics.gui.mngr_bod_aio import MngrBodAio
    from metrics.build_order_library import BuildOrderLibrary
    from metrics.metric_factory.spawningtool_factory import SpawningtoolFactory

    bol = BuildOrderLibrary()
    try:
        #bol.load_library("C:/Users/matthew/Documents/Starcraft2Metrics/build_library.json")
        bol.load_library("build_library.json")
    except:
        pass

    mngr = MngrBodAio(bol, SpawningtoolFactory(), "build_library.json")
    open_bod_window(mngr)
コード例 #6
0
    def test_IndexError_is_raised_from_remove_when_index_is_out_of_range(self):
        bol = BuildOrderLibrary(self.get_builds())

        self.assertRaises(IndexError, bol.remove_build_by_index, 3)
コード例 #7
0
    def test_build_is_removed_when_removing_by_index(self):
        bol = BuildOrderLibrary(self.get_builds())

        bol.remove_build_by_index(1)

        self.assertIsNone(bol.get_build_by_name("my_second"))
コード例 #8
0
    def test_none_is_returned_when_build_with_name_does_not_exist(self):
        bol = BuildOrderLibrary(self.get_builds())

        bo = bol.get_build_by_name("gggg")

        self.assertIsNone(bo)
コード例 #9
0
    def test_correct_build_is_returned_when_given_name(self):
        bol = BuildOrderLibrary(self.get_builds())

        bo = bol.get_build_by_name("my_second")

        self.assertEqual("my_second", bo.name)
コード例 #10
0
    def test_correct_build_is_returned_when_given_index(self):
        bol = BuildOrderLibrary(self.get_builds())

        bo = bol.get_build_by_index(2)

        self.assertEqual("my_third", bo.name)
コード例 #11
0
    def test_correct_build_count_is_returned(self):
        bol = BuildOrderLibrary(self.get_builds())

        self.assertEqual(3, bol.build_count())
コード例 #12
0
    def test_FileNotFoundError_is_raised_when_loading_library_with_empty_filename(
            self):
        bol = BuildOrderLibrary(self.get_builds())

        self.assertRaises(FileNotFoundError, bol.load_library, "")
コード例 #13
0
    def test_ValueError_is_raised_when_trying_to_remove_a_build_not_in_the_library(
            self):
        bol = BuildOrderLibrary(self.get_builds())
        bo = BuildOrder()

        self.assertRaises(ValueError, bol.remove_build_by_build_order, bo)
コード例 #14
0
    def test_no_builds_are_removed_if_invalid_name_is_given(self):
        bol = BuildOrderLibrary(self.get_builds())

        bol.remove_build_by_name("gggg")

        self.assertEqual(3, bol.build_count())