Add publish functionality to billing pipeline

This closes the end-to-end billing pipeline, allowing us to share generated detail reports with registrars via Drive and e-mail the invoicing team a link to the generated invoice.

This also factors out the email configs from ICANN reporting into the common 'misc' config, since we'll likely need alert e-mails for future periodic tasks.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=180805972
This commit is contained in:
larryruili 2018-01-04 09:16:51 -08:00 committed by jianglai
parent 27f12b9390
commit ab5e16ab67
25 changed files with 721 additions and 95 deletions

View file

@ -45,33 +45,35 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class GenerateInvoicesActionTest {
Dataflow dataflow = mock(Dataflow.class);
Projects projects = mock(Projects.class);
Templates templates = mock(Templates.class);
Launch launch = mock(Launch.class);
GenerateInvoicesAction action;
FakeResponse response = new FakeResponse();
@Rule
public final AppEngineRule appEngine = AppEngineRule.builder().withTaskQueue().build();
private Dataflow dataflow;
private Projects projects;
private Templates templates;
private Launch launch;
private FakeResponse response;
private GenerateInvoicesAction action;
@Before
public void initializeObjects() throws Exception {
public void setUp() throws IOException {
dataflow = mock(Dataflow.class);
projects = mock(Projects.class);
templates = mock(Templates.class);
launch = mock(Launch.class);
when(dataflow.projects()).thenReturn(projects);
when(projects.templates()).thenReturn(templates);
when(templates.launch(any(String.class), any(LaunchTemplateParameters.class)))
.thenReturn(launch);
when(launch.setGcsPath(any(String.class))).thenReturn(launch);
response = new FakeResponse();
Job job = new Job();
job.setId("12345");
when(launch.execute()).thenReturn(new LaunchTemplateResponse().setJob(job));
action = new GenerateInvoicesAction();
action.dataflow = dataflow;
action.response = response;
action.projectId = "test-project";
action.beamBucketUrl = "gs://test-project-beam";
action.yearMonth = new YearMonth(2017, 10);
action = new GenerateInvoicesAction(
"test-project", "gs://test-project-beam", new YearMonth(2017, 10), dataflow, response);
}
@Test
@ -99,7 +101,7 @@ public class GenerateInvoicesActionTest {
}
@Test
public void testCaughtIOException() throws Exception {
public void testCaughtIOException() throws IOException {
when(launch.execute()).thenThrow(new IOException("expected"));
action.run();
assertThat(response.getStatus()).isEqualTo(500);