Beispiel #1
0
 def test_KanePage_ssml(self):
     kane_page = KanePage(mocked=True)
     assert kane_page is not None
     status = kane_page.fetch_taplist(brewery='Kane')
     assert not status
     ssml = kane_page.ssml_taplist()
     assert ssml
     # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
     file_name = data_dir() + kane_page._brewery_name.replace(' ', '') + '.SSML'
     file_pointer = open(file_name, mode='r', encoding='utf8')
     tst_data = file_pointer.read()
     file_pointer.close()
     assert tst_data == ssml  # anything different, raise hell!
Beispiel #2
0
    def test_TEB_beerlist(self):
        """Test we can read the Twin Elephant beer list!"""
        teb = TEBpage(mocked=True)
        assert teb is not None
        teb.fetch_taplist(brewery="Twin Elephant")
        beer_string = teb.ssml_taplist()
        assert beer_string is not None

        # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
        file_name = data_dir() + teb._brewery_name.replace(' ', '') + '.SSML'
        file_pointer = open(file_name, mode='r', encoding='utf8')
        tst_data = file_pointer.read()
        file_pointer.close()
        assert tst_data == beer_string  # anything different, raise hell!
Beispiel #3
0
    def test_untied_brewing_mocked(self):
        """Special testing for Untied Brewing since it does special parsing"""
        brewery_name = "Untied"
        untapped_page = UnTappdPage(mocked=True)
        untapped_page.fetch_taplist(brewery=brewery_name)
        beer_string = untapped_page.ssml_taplist()
        assert beer_string is not None

        # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
        file_name = data_dir() + brewery_name.replace(' ', '') + '.SSML'
        file_pointer = open(file_name, 'r', encoding='utf-8')
        tst_data = file_pointer.read()
        file_pointer.close()
        if tst_data != beer_string:
            assert tst_data == beer_string  # anything different, raise hell!
Beispiel #4
0
    def test_DigitalPour_beerlist(self):
        """Test & validate beer list for this provider"""
        ut = DigitalPourPage(mocked=True)
        assert ut is not None
        for brewery in BREWERY_INFO:
            ut.fetch_taplist(brewery=brewery)
            beer_string = ut.ssml_taplist()
            assert beer_string is not None

            # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
            file_name = data_dir() + brewery.replace(' ', '') + '.SSML'
            file_pointer = open(file_name, 'r')
            tst_data = file_pointer.read()
            file_pointer.close()
            assert tst_data == beer_string  # anything different, raise hell!
Beispiel #5
0
    def test_DepartedSoles_beerlist(self):
        """Test we can get back a properly parsed beer list"""
        dsp = DepartedSolespage(mocked=True)
        assert dsp is not None

        dsp.fetch_taplist(brewery='Departed Soles')
        beer_string = dsp.ssml_taplist()
        assert beer_string is not None

        # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
        file_name = data_dir() + dsp._brewery_name.replace(' ', '') + '.SSML'
        file_pointer = open(file_name, 'r')
        tst_data = file_pointer.read()
        file_pointer.close()
        assert tst_data == beer_string  # anything different, raise hell!
Beispiel #6
0
    def test_BeerMenus_beerlist(self):
        """Test that we get back a properly parsed beer list"""
        ut = BeerMenusPage(mocked=True)
        assert ut is not None
        for brewery in BREWERY_INFO:
            ut.fetch_taplist(brewery=brewery)
            beer_string = ut.ssml_taplist()
            assert beer_string is not None

            # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
            fn = data_dir() + brewery.replace(' ', '') + '.SSML'
            fp = open(fn, mode='r', encoding='utf8')
            tst_data = fp.read()
            fp.close()
            assert tst_data == beer_string  # anything different, raise hell!
Beispiel #7
0
 def test_UnTappd_mocked_brewery(self):
     """Test that we cna read brewery pages and validate results"""
     untapped_page = UnTappdPage(mocked=True)
     for brewery_name in BREWERY_INFO:
         # we are mocking the URL, reading a local test file (../tests/data/<brewery>.HTML)
         assert untapped_page is not None
         untapped_page.fetch_taplist(brewery=brewery_name)
         beer_string = untapped_page.ssml_taplist()
         assert beer_string is not None
         # read our pre-canned response to compare with (../tests/data/<brewery>.SSML)
         file_name = data_dir() + brewery_name.replace(' ', '') + '.SSML'
         file_pointer = open(file_name, 'r', encoding='utf-8')
         tst_data = file_pointer.read()
         file_pointer.close()
         if tst_data != beer_string:
             assert tst_data == beer_string  # anything different, raise hell!
Beispiel #8
0
    def test_UnTapped_mocked_brewery_in_cache(self):

        # ensure we start with an empty cache
        brewery_name = next(iter(BREWERY_INFO))
        cloudredis.flush_cache(brewery_name)

        # fetch our brewery information
        untapped_page = UnTappdPage(mocked=True)
        untapped_page.fetch_taplist(brewery=brewery_name)
        uncached_html = untapped_page.ssml_taplist()

        # now let's get it from the cache
        untapped_page = UnTappdPage(mocked=True)
        untapped_page.fetch_taplist(brewery=brewery_name)
        cached_html = untapped_page.ssml_taplist()

        assert cached_html == uncached_html

        # now check the value returned
        file_name = data_dir() + brewery_name.replace(' ', '') + '.HTML'
        file_pointer = open(file_name, mode='r', encoding='utf8')
        brewery_html = file_pointer.read()
        file_pointer.close()
        assert cloudredis.is_cached(brewery_name, brewery_html)