def test_view_counter_state(): key_store = DictKeyValueStore() field_data = KvsFieldData(key_store) runtime = TestRuntime(services={'field-data': field_data}) tester = ViewCounter(runtime, scope_ids=Mock()) assert_equals(tester.views, 0) # View the XBlock five times for i in xrange(5): generated_html = tester.student_view({}) # Make sure the html fragment we're expecting appears in the body_html assert_in('<span class="views">{0}</span>'.format(i + 1), generated_html.body_html()) assert_equals(tester.views, i + 1)
def test_view_counter_state(): key_store = DictKeyValueStore() db_model = KvsFieldData(key_store) tester = ViewCounter(Mock(), db_model, Mock()) assert_equals(tester.views, 0) # View the XBlock five times for i in xrange(5): generated_html = tester.student_view({}) # Make sure the html fragment we're expecting appears in the body_html assert_in('<span class="views">{0}</span>'.format(i + 1), generated_html.body_html()) assert_equals(tester.views, i + 1)
def test_view_counter_state(): key_store = DictKeyValueStore() field_data = KvsFieldData(key_store) runtime = Runtime(services={'field-data': field_data}) tester = ViewCounter(runtime, scope_ids=Mock()) assert tester.views == 0 # View the XBlock five times for i in range(5): generated_html = tester.student_view({}) # Make sure the html fragment we're expecting appears in the body_html assert f'<span class="views">{i + 1}</span>' in generated_html.body_html() assert tester.views == (i + 1)