<s> from performanceplatform . collector . ga . plugins . department import ComputeDepartmentKey , try_get_department <EOL> def test_try_get_department ( ) : <EOL> from nose . tools import assert_equal <EOL> assert_equal ( try_get_department ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> assert_equal ( try_get_department ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> assert_equal ( try_get_department ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> def test_mapping ( ) : <EOL> from nose . tools import assert_equal , assert_in <EOL> plugin = ComputeDepartmentKey ( "<STR_LIT>" ) <EOL> documents = [ { "<STR_LIT>" : "<STR_LIT>" } ] <EOL> ( transformed_document , ) = plugin ( documents ) <EOL> assert_in ( "<STR_LIT>" , transformed_document ) <EOL> assert_equal ( transformed_document [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" ) <EOL> def test_fail_if_no_key_name_in_document ( ) : <EOL> from nose . tools import assert_raises <EOL> plugin = ComputeDepartmentKey ( "<STR_LIT>" ) <EOL> documents = [ { "<STR_LIT:foo>" : "<STR_LIT>" } ] <EOL> with assert_raises ( AssertionError ) : <EOL> plugin ( documents ) <EOL> def test_unknown_department_code ( ) : <EOL> from nose . tools import assert_equal <EOL> plugin = ComputeDepartmentKey ( "<STR_LIT>" ) <EOL> documents = [ { "<STR_LIT>" : "<STR_LIT>" } ] <EOL> ( transformed_document , ) = plugin ( documents ) <EOL> assert_equal ( transformed_document [ "<STR_LIT>" ] , "<STR_LIT>" ) <EOL> def test_takes_first_code ( ) : <EOL> from nose . tools import assert_equal <EOL> plugin = ComputeDepartmentKey ( "<STR_LIT>" ) <EOL> documents = [ { "<STR_LIT>" : "<STR_LIT>" } ] <EOL> ( transformed_document , ) = plugin ( documents ) <EOL> assert_equal ( transformed_document [ "<STR_LIT>" ] , <EOL> "<STR_LIT>" ) </s>
